<?php
$get_condition = '';
$cont = 0;
$evaluar = '';

if($_POST['track']!='') {
    $get_condition .= "id_track=".$_POST['track'];
    $evaluar = 1;
    $cont = 1;
}

if($_POST['estado']!='') {
    if($cont==1) {
        $get_condition .= "&";
    }
    $get_condition .= "estado=".utf8_decode($_POST['estado'])."";
    $cont = 2;
}

if($_POST['idioma']!='') {
    if(($cont==2) OR ($cont==1)) {
        $get_condition .= "&";
    }
    $get_condition .= "id_idioma=".$_POST['idioma'];
}

if($get_condition!=' ') {
    $get_condition = "&".$get_condition;
}

if(($_GET['id_track'])||($_GET['estado'])||($_GET['id_idioma'])) {
    $get_condition = '';
    $cont = 0;
    $evaluar = '';

    if($_GET['id_track']!='') {
        $get_condition .= "id_track=".$_GET['id_track'];
        $evaluar = 1;
        $cont = 1;
    }

    if($_GET['estado']!='') {
        if($cont==1) {
            $get_condition .= "&";
        }
        $get_condition .= "estado=".utf8_decode($_GET['estado'])."";
        $cont = 2;
    }

    if($_GET['id_idioma']!='') {
        if(($cont==2) OR ($cont==1)) {
            $get_condition .= "&";
        }
        $get_condition .= "id_idioma=".$_GET['id_idioma'];
    }

    if($get_condition!=' ') {
        $get_condition = "&".$get_condition;
    }
}

if($this->vars['data_paper']['pages'] > 1) {
    $controller = strip_tags($_GET['controller']);
    if($this->vars['page'] > 1) {
        echo("<<&nbsp;<a href=\"index.php?controller=" .$controller. "&action=buscar&page=" .($this->vars['page'] - 1). "".$get_condition."\">anterior</a>&nbsp;");
    }
    $i = 1;
    for($i; $i <= $this->vars['data_paper']['pages']; $i++) {
        if($i == $this->vars['page']) {
            echo($i . "&nbsp;");
        }
        else {
            echo("<a href=\"index.php?controller=" .$controller. "&action=buscar&page=" .($i). "".$get_condition."\">" .($i). "</a>&nbsp;");
        }
    }
    if($this->vars['page'] < $this->vars['data_paper']['pages']) {
        echo("<a href=\"index.php?controller=" .$controller. "&action=buscar&page=" .($this->vars['page'] + 1). "".$get_condition."\">siguiente</a>&nbsp;>>");
    }
}
?>